<%@page import="javax.persistence.PersistenceContextType"%>
<%@ page import="domain.model.user.mapper.UserInputMapper"%>
<%@ page import="domain.model.user.User"%>
<%@ page import="application.filter.PermaLinkFilter" %>
<%@ page import="application.filter.PermaLinkFilter.Commands" %>

<%
	if(request.getSession()!=null && request.getSession().getAttribute("userid")!=null)
	{
		User user = UserInputMapper.find((Long)(request.getSession().getAttribute("userid")));
		
		Commands cmd = (Commands) request.getAttribute("currentCommand");
		
		boolean isAdmin = (Boolean) request.getSession().getAttribute("userisadmin");
		if(user.getGroup().getId() != 0) // if the user is in a group
		{
%>
			<ul id="menu">
				<li <% if(cmd == Commands.browsegroups) { %>class="active"<%}%> ><a href="browsegroups">Groups</a></li>
				<li <% if(cmd == Commands.inviteuser) { %>class="active"<%}%> ><a href="inviteuser"><span> Invite </span></a></li>
				<li <% if(cmd == Commands.browserequests) { %>class="active"<%}%> ><a href="browserequests"><span> Requests</span></a></li>
				<li <% if(cmd == Commands.viewgroup) { %>class="active"<%}%> ><a href="viewgroup"><span> My Group </span></a></li>
				
				<!-- <li><a href="editgroup"><span>Edit Group</span></a></li>
				<li><a href="removegroup"><span>Remove Group</span></a></li>
				<li><a href="removemember"><span>Remove Member</span></a></li> -->
				
				<%if( isAdmin ){ %>
					<li <% if(cmd == Commands.adduser) { %>class="active"<%}%> >
						<a href="adduser"> Add User </a>
					</li>
				<%} %>
			</ul>
<%		
		}
		else
		{
%>
			<ul id="menu">
				<li <% if(cmd == Commands.browsegroups) { %>class="active"<%}%> ><a href="browsegroups"> Groups </a></li>
				<li <% if(cmd == Commands.browseinvites) { %>class="active"<%}%> ><a href="browseinvites"><span> My Invites </span></a></li>
				<!-- <li><a href="requestinvite"><span> Request </span></a></li> -->
				<li <% if(cmd == Commands.creategroup) { %>class="active"<%}%> ><a href="creategroup"><span> Create Group </span></a></li>
				<%if( isAdmin ){ %>
				<li <% if(cmd == Commands.adduser) { %>class="active"<%}%> >
					<a href="adduser">Add New User</a>
				</li>
				<%} %>
			</ul>
<%		
		}
	}
%>

